<template>
    <div>
<h2>登录</h2>
<table>
    <tbody>
        <tr>
            <td>名称</td>
            <td>
                <input type="text" v-model="data.name">
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="password" v-model="data.pwd">
            </td>
        </tr>
        <tr>
            <td>
                <input type="button" value="登录" @click="Login">
            </td>
        </tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import axios from 'axios';
const data=ref({
  name: "",
  pwd: ""
})

const Login=()=>{
    axios.get("https://localhost:7227/api/Member/Login",{params:data.value}).then(res=>{
        if(res.data.id==-1){
            alert("名称不正确");
            return;
        }
        if(res.data.id==-2){
            alert("密码不正确");
            return;
        }
        if(res.data.id>0){
            alert("登录成功");
            location.href="/"
        }
    })
}
</script>

<style scoped>

</style>